extends Camera2D
var player: Player = null
var end_pos: Vector2 = Vector2.ZERO

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	player = get_parent().get_node("player")
	global_position = player.global_position

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	global_position = lerp(acquire_target_pos(), global_position, pow(2, -15 * delta))


func acquire_target_pos() -> Vector2:
	if (is_instance_valid(player)):
		return player.global_position
	else:
		end_pos = global_position
		return end_pos
